package com.example.md.mddemo.easypoi;

import cn.afterturn.easypoi.excel.entity.result.ExcelVerifyHandlerResult;
import cn.afterturn.easypoi.handler.inter.IExcelVerifyHandler;
import org.apache.commons.lang3.StringUtils;

/**
 * Copyright © 2018年 ziniuxiaozhu. All rights reserved.
 *
 * @Author 临江仙 hzqiuxm@163.com
 * TODO:亲爱的临江仙，请写点注释吧...........
 * @Date 2018/8/20 20:52
 */
public class ExcelVerifyHandlerImpl implements IExcelVerifyHandler<ExeclCustomer> {
    @Override
    public ExcelVerifyHandlerResult verifyHandler(ExeclCustomer execlCustomer) {

        StringBuilder builder = new StringBuilder();

        if (!StringUtils.isNoneEmpty(execlCustomer.getCustName())){

            System.out.println("=======================execlCustomer.getCustName()====================="+execlCustomer.getCustName());
            builder.append("客户姓名不能为空!");
            return new ExcelVerifyHandlerResult(false, builder.toString());
        }

        if (!StringUtils.isNoneEmpty(execlCustomer.getBalanceDate())){

            builder.append("到期时间不能为空!");
            return new ExcelVerifyHandlerResult(false, builder.toString());
        }

        if (!StringUtils.isNoneEmpty(execlCustomer.getCustGradeName())){

            builder.append("客户等级不能为空!");
            return new ExcelVerifyHandlerResult(false, builder.toString());
        }

        if (!StringUtils.isNoneEmpty(execlCustomer.getLegalPerson())){

            builder.append("法人代表不能为空!");
            return new ExcelVerifyHandlerResult(false, builder.toString());
        }

        if (!StringUtils.isNoneEmpty(execlCustomer.getIdentification())){

            builder.append("纳税识别号不能为空!");
            return new ExcelVerifyHandlerResult(false, builder.toString());
        }

        if (!StringUtils.isNoneEmpty(execlCustomer.getCustType())){

            builder.append("客户类型不能为空!");
            return new ExcelVerifyHandlerResult(false, builder.toString());
        }

        return new ExcelVerifyHandlerResult(true, builder.toString());
    }
}
